package com.azure.grpcserver;

import com.azure.grpc.lib.HelloReply;
import com.azure.grpc.lib.HelloRequest;
import com.azure.grpc.lib.SimpleGrpc;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;

import java.util.Date;

@GrpcService
public class SimpleGrpcImpl extends SimpleGrpc.SimpleImplBase {
    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
        System.out.println("客户端："+request.getName()+"调过来了");
        HelloReply reply = HelloReply.newBuilder().setMessage("你好， " + request.getName() + ", " + new Date()).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}
